package com.acmen.demo.service;

import com.acmen.demo.executor.UserSaveExe;
import com.acmen.easyapi.model.CustomizePage;
import com.acmen.easyapi.model.Response;
import com.acmen.demo.dto.cmd.UserAdd;
import com.acmen.demo.dto.cmd.UserUpd;
import com.acmen.demo.dto.query.UserListQry;
import com.acmen.demo.dto.query.UserPageQry;
import com.acmen.demo.dto.vo.UserVO;
import com.acmen.demo.executor.UserDeleteExe;
import com.acmen.demo.executor.UserQueryExe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 用户 业务层处理
 *
 * @author acmen
 */
@Service
public class UserService {
    private static final Logger log = LoggerFactory.getLogger(UserService.class);
    @Resource
    private UserSaveExe userSaveExe;
    @Resource
    private UserDeleteExe userDeleteExe;
    @Resource
    private UserQueryExe userQueryExe;


    /**
     * 分页查询用户信息
     */
    public Response<CustomizePage<UserVO>> selectPage(UserPageQry query) {
        return userQueryExe.selectPage(query);
    }

    /**
     * 查询用户列表
     */
    public Response<List<UserVO>> selectList(UserListQry query) {
        return userQueryExe.selectList(query);
    }

    public Response<UserVO> selectById(Long id) {
        return userQueryExe.selectById(id);
    }

    /**
     * 新增用户
     */
    public Response create(UserAdd user) {
        return userSaveExe.create(user);
    }

    /**
     * 修改用户
     */
    public Response update(UserUpd user) {
        return userSaveExe.update(user);
    }

    /**
     * 获取当前用户信息
     * @return
     */
    public Response<UserVO> getCurrentUser() {
        return userQueryExe.getCurrentUser();
    }

    /**
     * 删除用户
     */
    public Response delete(List<Long> userIds) {
        return userDeleteExe.delete(userIds);
    }


}
